package com.google.android.gms.internal;

import java.io.IOException;

public final class zzbd extends zzflm<zzbd> {
    private Long zzgf = null;
    private Integer zzgg = null;
    private Boolean zzgh = null;
    private int[] zzgi = zzflv.zzpvy;
    private Long zzgj = null;

    public zzbd() {
        this.zzpnr = -1;
    }

    public final /* synthetic */ zzfls zza(zzflj zzflj) throws IOException {
        while (true) {
            int zzcxx = zzflj.zzcxx();
            if (zzcxx == 0) {
                return this;
            }
            if (zzcxx == 8) {
                this.zzgf = Long.valueOf(zzflj.zzcyr());
            } else if (zzcxx == 16) {
                this.zzgg = Integer.valueOf(zzflj.zzcym());
            } else if (zzcxx == 24) {
                this.zzgh = Boolean.valueOf(zzflj.zzcyd());
            } else if (zzcxx == 32) {
                int zzb = zzflv.zzb(zzflj, 32);
                int length = this.zzgi == null ? 0 : this.zzgi.length;
                int[] iArr = new int[(zzb + length)];
                if (length != 0) {
                    System.arraycopy(this.zzgi, 0, iArr, 0, length);
                }
                while (length < iArr.length - 1) {
                    iArr[length] = zzflj.zzcym();
                    zzflj.zzcxx();
                    length++;
                }
                iArr[length] = zzflj.zzcym();
                this.zzgi = iArr;
            } else if (zzcxx == 34) {
                int zzli = zzflj.zzli(zzflj.zzcym());
                int position = zzflj.getPosition();
                int i = 0;
                while (zzflj.zzcyo() > 0) {
                    zzflj.zzcym();
                    i++;
                }
                zzflj.zzmw(position);
                int length2 = this.zzgi == null ? 0 : this.zzgi.length;
                int[] iArr2 = new int[(i + length2)];
                if (length2 != 0) {
                    System.arraycopy(this.zzgi, 0, iArr2, 0, length2);
                }
                while (length2 < iArr2.length) {
                    iArr2[length2] = zzflj.zzcym();
                    length2++;
                }
                this.zzgi = iArr2;
                zzflj.zzlj(zzli);
            } else if (zzcxx == 40) {
                this.zzgj = Long.valueOf(zzflj.zzcyr());
            } else if (!super.zza(zzflj, zzcxx)) {
                return this;
            }
        }
    }

    public final void zza(zzflk zzflk) throws IOException {
        if (this.zzgf != null) {
            zzflk.zzf(1, this.zzgf.longValue());
        }
        if (this.zzgg != null) {
            zzflk.zzad(2, this.zzgg.intValue());
        }
        if (this.zzgh != null) {
            zzflk.zzl(3, this.zzgh.booleanValue());
        }
        if (this.zzgi != null && this.zzgi.length > 0) {
            for (int zzad : this.zzgi) {
                zzflk.zzad(4, zzad);
            }
        }
        if (this.zzgj != null) {
            zzflk.zza(5, this.zzgj.longValue());
        }
        super.zza(zzflk);
    }

    /* access modifiers changed from: protected */
    public final int zzq() {
        int zzq = super.zzq();
        if (this.zzgf != null) {
            zzq += zzflk.zzc(1, this.zzgf.longValue());
        }
        if (this.zzgg != null) {
            zzq += zzflk.zzag(2, this.zzgg.intValue());
        }
        if (this.zzgh != null) {
            this.zzgh.booleanValue();
            zzq += zzflk.zzlw(3) + 1;
        }
        if (this.zzgi != null && this.zzgi.length > 0) {
            int i = 0;
            for (int zzlx : this.zzgi) {
                i += zzflk.zzlx(zzlx);
            }
            zzq = zzq + i + (1 * this.zzgi.length);
        }
        if (this.zzgj == null) {
            return zzq;
        }
        return zzq + zzflk.zzlw(5) + zzflk.zzdj(this.zzgj.longValue());
    }
}
